package com.tedu.oop.day2;
//测试构造 局部 代码块   block-块
public class Test2_Block {
    public static void main(String[] args) {
        Teacher1 t=new Teacher1();
        t.prepareClass();
        t.teachClass();
        System.out.println("=================");
        Teacher1 t1=new Teacher1();
        t1.prepareClass();
        t1.teachClass();
    }

}
class Teacher1{

    private String name;
    private String subject;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public Teacher1() {

    }

    public Teacher1(String name, String subject) {
        this.name = name;
        this.subject = subject;
    }
    {
        System.out.println("构造代码块");
    }

    public void prepareClass(){

        System.out.println("正在备课...");

        {
            int a=10;
            System.out.println(a);//只能在所在的{} 中使用
            System.out.println("局部代码块");
        }

    }
    public void teachClass(){
        System.out.println("正在讲课...");
    }
}
